require 'rom'
require 'rom-sql'

# 配置数据库
rom = ROM.container(:sql, 'mysql2://root:root@192.168.3.54/iai') do |config|
  config.relation(:fa_article) do
    schema(infer: true) # 自动推断表结构
  end
end

# 获取数据集
article = rom.relations[:fa_article]

# # 插入数据
# users.insert(name: 'Charlie', email: 'charlie@example.com')

# # 查询数据
# users.where(name: 'Charlie').each { |user| puts user[:email] }

# # 更新数据
# users.where(name: 'Charlie').update(email: 'new_charlie@example.com')

# # 删除数据
# users.where(name: 'Charlie').delete

# article.insert(title: 'Hello, World!', content: 'This is my first article.', resource: '1,2,3')
today = Time.new
puts today
puts today.to_i
article.insert(title: 'Hello, World!', content: 'This is my first article.', create_time: today.to_i, update_time: today.to_i, resource: '')



